cmake_minimum_required(VERSION 3.16)

project(test2 VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(sources_file  "src/com/get_com_message.cpp"
  "src/com/find_com.cpp"
  "src/com/com_connect.cpp"
  "src/com/send_message_com.cpp"
  "src/GPS/get_uav_location.cpp"
)
set(headers_file  "include/com/get_com_message.hpp"
  "include/com/find_com.hpp"
  "include/com/com_connect.hpp"
  "include/com/send_message_com.hpp"
  "include/GPS/get_uav_location.hpp"
)
set(qml_file "qml/Main.qml" 
  "qml/qmlPart/MyMap.qml"
  "qml/qmlPart/ComSelect.qml"
  "qml/qmlPart/TopWindow.qml"
)
set(web_resources "source/map/index.html"
  "source/map/js/script.js"
  "source/map/css/styles.css"
)
include_directories("./include")

find_package(Qt6 6.4 REQUIRED COMPONENTS Quick Location Positioning SerialPort WebEngineQuick)

qt_standard_project_setup()

qt_add_executable(apptest2
  src/main.cpp
)

qt_add_qml_module(apptest2
  URI test2
  VERSION 1.0
  QML_FILES ${qml_file}
    SOURCES ${sources_file}
    SOURCES ${headers_file}
    # 添加HTML文件作为资源
    RESOURCES ${web_resources}
)

set_target_properties(apptest2 PROPERTIES
  MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
  MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
  MACOSX_BUNDLE TRUE
  WIN32_EXECUTABLE TRUE
)

# 添加 WebEngineQuick 链接
target_link_libraries(apptest2
  PRIVATE Qt6::Quick Qt6::Location Qt6::Positioning Qt6::SerialPort Qt6::WebEngineQuick
)

include(GNUInstallDirs)
install(TARGETS apptest2
  BUNDLE DESTINATION .
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
